// pages/seach/seach.js
const app = getApp()
Page({
  data: {
    
  },
  //事件处理函数
  onLoad: function () {

  },
  onShow(){
    var that = this;
    if (typeof this.getTabBar === 'function' &&
      this.getTabBar()) {
      this.getTabBar().setData({
        selected: 1,
      })
      if (app.globalData.userInfo !== null && app.globalData.userInfo.hasShop) {
        this.getTabBar().setData({
          hasShop: true,
        })
      } else {
        const that = this
        common.post({
          url: '/app/user/getInfo', data: { sessionId: this.data.sessionId }
        })
          .then((res) => {
            console.log(res.data)
            app.globalData.userInfo = res.data.data
            if (res.data.data.hasShop) {
              this.getTabBar().setData({
                hasShop: true,
              })
            } else {
              this.getTabBar().setData({
                hasShop: false,
              })
            }
          }).catch((res) => {
            console.log(res)
          })
      }
    }
  }
})
